package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysInOutMapper;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.SysInOut;
import com.ruoyi.system.service.ISysInOutService;

/**
 * 出入库台账Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-30
 */
@Service
public class SysInOutServiceImpl implements ISysInOutService
{
    @Autowired
    private SysInOutMapper sysInOutMapper;

    /**
     * 查询出入库台账
     *
     * @param outId 出入库台账主键
     * @return 出入库台账
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public SysInOut selectSysInOutByOutId(Long outId)
    {
        return sysInOutMapper.selectSysInOutByOutId(outId);
    }

    /**
     * 查询出入库台账列表
     *
     * @param sysInOut 出入库台账
     * @return 出入库台账
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<SysInOut> selectSysInOutList(SysInOut sysInOut)
    {
        return sysInOutMapper.selectSysInOutList(sysInOut);
    }

    /**
     * 新增出入库台账
     *
     * @param sysInOut 出入库台账
     * @return 结果
     */
    @Override
    public int insertSysInOut(SysInOut sysInOut)
    {
        // 设置当前登录用户的部门和用户ID
        sysInOut.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
        sysInOut.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());

        sysInOut.setCreateTime(DateUtils.getNowDate());
        return sysInOutMapper.insertSysInOut(sysInOut);
    }

    /**
     * 修改出入库台账
     *
     * @param sysInOut 出入库台账
     * @return 结果
     */
    @Override
    public int updateSysInOut(SysInOut sysInOut)
    {
        sysInOut.setUpdateTime(DateUtils.getNowDate());
        return sysInOutMapper.updateSysInOut(sysInOut);
    }

    /**
     * 批量删除出入库台账
     *
     * @param outIds 需要删除的出入库台账主键
     * @return 结果
     */
    @Override
    public int deleteSysInOutByOutIds(Long[] outIds)
    {
        return sysInOutMapper.deleteSysInOutByOutIds(outIds);
    }

    /**
     * 删除出入库台账信息
     *
     * @param outId 出入库台账主键
     * @return 结果
     */
    @Override
    public int deleteSysInOutByOutId(Long outId)
    {
        return sysInOutMapper.deleteSysInOutByOutId(outId);
    }
}
